Skip to content

gh-61481: Document that memoryview, range, and slice cannot be subclassed#153766

Open
soreavis wants to merge 1 commit into
python:mainfrom
soreavis:gh-61481-subclass-note
Open

gh-61481: Document that memoryview, range, and slice cannot be subclassed#153766
soreavis wants to merge 1 commit into
python:mainfrom
soreavis:gh-61481-subclass-note

Conversation

@soreavis

@soreavis soreavis commented Jul 15, 2026

Copy link
Copy Markdown

Among the built-in classes that can't be subclassed, only bool documents it. memoryview, range, and slice behave the same but say nothing, so it can only be found out by trying. Add the same note to those three.

The wording mirrors the existing bool entry, minus the "further" that applies only to bool (which subclasses int). Confirmed at tip: subclassing each raises TypeError (they lack Py_TPFLAGS_BASETYPE), while int and list allow it.

This is the note the issue author proposed, and the thread confirmed all four are intentional rather than oversights. The types module classes mentioned in the issue are documented separately and are out of scope here.

…subclassed

Among the built-in classes that can't be subclassed, only bool documents
it. memoryview, range, and slice behave the same but say nothing, so it
can only be found out by trying. Add the same note to those three.

The wording mirrors the existing bool entry, minus the "further" that
applies only to bool (which subclasses int).
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33599059 | 📁 Comparing df5121b against main (4f3be1b)

  🔍 Preview build  

1 file changed
± library/functions.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant